package com.xsmous.open.kryo;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Output;
import com.xsmous.open.codec.UserBean;
import com.xsmous.open.constants.Constant;
import org.objenesis.strategy.StdInstantiatorStrategy;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

/**
 * @author 雨一直夏灬
 * @since 2020/5/30 11:26 上午
 * 年少无为、码上为生
 */
public class KryoDemo {

    public static void main(String[] args) throws FileNotFoundException {
        Kryo kryo = new Kryo();
        kryo.setReferences(false);
        kryo.setRegistrationRequired(false);
        kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
        Output output = new Output(new FileOutputStream(Constant.OutputDir + "kryo.bin"));
        kryo.writeClassAndObject(output, UserBean.getUserBean());
        output.flush();
    }
}
